#include "Service.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Service_classType = NULL;
VTable* Service_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Bool equals(Obj? that) */
Bool Service_equals(Service* self, NullableObj that)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.equals not implemented yet"));
}


/* Int hash() */
Int Service_hash(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.hash not implemented yet"));
}


/* Service[] list() */
List* Service_list(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.list not implemented yet"));
}


/* Service? find(Type t, Bool checked) */
Service* Service_find_1(Type* t)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.find not implemented yet"));
}


/* Service? find(Type t, Bool checked) */
Service* Service_find(Type* t, Bool checked)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.find not implemented yet"));
}


/* Service[] findAll(Type t) */
List* Service_findAll(Type* t)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.findAll not implemented yet"));
}


/* Bool isInstalled() */
Bool Service_isInstalled(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.isInstalled not implemented yet"));
}


/* Bool isRunning() */
Bool Service_isRunning(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.isRunning not implemented yet"));
}


/* This install() */
Service* Service_install(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.install not implemented yet"));
}


/* This start() */
Service* Service_start(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.start not implemented yet"));
}


/* This stop() */
Service* Service_stop(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.stop not implemented yet"));
}


/* This uninstall() */
Service* Service_uninstall(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.uninstall not implemented yet"));
}


/* Void onStart() */
void Service_onStart(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.onStart not implemented yet"));
}


/* Void onStop() */
void Service_onStop(Service* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Service.onStop not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Service_initType(void)
{
  if (Service_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Service_initVTable();
    Type* type = Type_new("Service", baseType, vtable, sizeof(Service), sizeof(ServiceVTable));
    Type_registerMethodImplementation(type, "equals", Service_equals, 1);
    Type_registerMethodImplementation(type, "find", Service_find_1, 1);
    Type_registerMethodImplementation(type, "find", Service_find, 2);
    Type_registerMethodImplementation(type, "findAll", Service_findAll, 1);
    Type_registerMethodImplementation(type, "hash", Service_hash, 0);
    Type_registerMethodImplementation(type, "install", Service_install, 0);
    Type_registerMethodImplementation(type, "isInstalled", Service_isInstalled, 0);
    Type_registerMethodImplementation(type, "isRunning", Service_isRunning, 0);
    Type_registerMethodImplementation(type, "list", Service_list, 0);
    Type_registerMethodImplementation(type, "onStart", Service_onStart, 0);
    Type_registerMethodImplementation(type, "onStop", Service_onStop, 0);
    Type_registerMethodImplementation(type, "start", Service_start, 0);
    Type_registerMethodImplementation(type, "stop", Service_stop, 0);
    Type_registerMethodImplementation(type, "uninstall", Service_uninstall, 0);
    Service_classType = type;
    Service_initStatic();
  }
  return Service_classType;
}


VTable* Service_initVTable(void)
{
  if (Service_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(ServiceVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((ServiceVTable*)vtable)->onStart = Service_onStart;
    ((ServiceVTable*)vtable)->onStop = Service_onStop;
    Service_classVTable = vtable;
  }
  return Service_classVTable;
}


void Service_initStatic(void)
{
}
